package commonClass;


/**
 * String类练习
 */
public class StringExercise03 {

    String str = new String("lmy");

    final char[] ch = {'j', 'a', 'v', 'a'};

    public void change(String str, char ch[]){
        str = "java";
        ch[0] = 'h';
    }

    public static void main(String[] args) {
        StringExercise03 stringExercise03 = new StringExercise03();
        //此时开辟新栈空间执行 change()方法，change()栈中的str指向 stringExercise03.str ，ch[] 指向 stringExercise03.ch
        //然后方法中 change()栈中str指向被修改为常量池中的“java”空间，ch[0]修改为h
        stringExercise03.change(stringExercise03.str, stringExercise03.ch);
        //执行完change()后会到main栈，此时 stringExercise03.str 指向不变
        //stringExercise03.ch 被修改成hava
        System.out.print(stringExercise03.str + "and");
        System.out.println(stringExercise03.ch);//lmyandhava
    }
}
